<template>
  <div class="box">
    <h2>Son1 </h2>
    从vuex中获取的值: <label>{{$store.state.user.count}}</label>
    <br>
    <button @click="addCount">修改count + 1</button>
    <button @click="asyncUpdate">异步修改数据</button>
    <br>
    <ul>
      <li v-for="item in $store.getters['user/oushuGetters']" :key="item">{{item}}</li>
    </ul>
  </div>
</template>

<script>
import { mapMutations, mapActions } from 'vuex'

export default {
  name: 'Son1Com',
  created(){
    // console.log(this.$store.getters.user.oushuGeeters);
    console.log(this.$store.getters['user/oushuGetters']);
  },
  methods: {
    ...mapMutations('user', ['updateCountMutations']),
    ...mapActions('user', ['updateCountActions']),
    addCount() {
      // this.$store.commit('user/updateCountMutations', 1)
      this.updateCountMutations(1)
    },
    asyncUpdate(){
      // this.$store.dispatch('user/updateCountActions', 3)
      this.updateCountActions(3)
    }
  }
}
</script>

<style lang="css" scoped>
.box{
  border: 3px solid #ccc;
  width: 400px;
  padding: 10px;
  margin: 20px;
}
h2 {
  margin-top: 10px;
}
</style>